package com.briup.day25;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListDemo {
	
	public static void main(String[] args) {
		List list = new ArrayList();
		list.add("hi");
		list.add("ho");
		list.add("haa");
		list.add("wrp");
		list.add("hinm");
		
		//随机访问
		list.add(2, "baoyan");
		
		list.set(3, "hahha");
		
		list.remove(4);
		
		System.out.println("第三个元素是"+list.get(3));
		
		//print(list);
		
		//size+get遍历
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i));
		}
	}
	
	public static void print(List list) {
		Iterator iterator = list.iterator();
		while (iterator.hasNext()) {
			System.out.println(iterator.next());
			
		}
	}

}
